#ifndef _ENTRYARRAY_H_CSEAPI_
#define _ENTRYARRAY_H_CSEAPI_

// CseNull is dummy mapped to CSE object: (const TCseObj&) NULL
extern CSE_IMPEXP_IN CseObj CseNull;

class CSE_IMPEXP_IN TEntryArray
{
private:
    void enlargeDict(int size);
    void joinEx(PEntryPoint pSour);
    void setEx_(CseObj key, CseObj value, TUint32 hash, CseObj *OldValue=NULL);

protected:
    PEntryPoint m_data;

public:
    TEntryArray();
    TEntryArray(int MagicNum, TEntryArray& entry);
    
    TEntryArray(int n);
    TEntryArray(const TEntryArray& entry);
    TEntryArray(PEntryPoint pSour); // system reserved, should pass pSour = NULL
    ~TEntryArray();

    TEntryArray& join(const TEntryArray& entry);

    TEntryArray& operator=(const TEntryArray& entry);
    void operator+=(const TEntryArray& entry);

    PEntryPoint addr() const;
    int len() const;
    TBool isEmpty() const;
    TInt compare(const TEntryArray& dOther) const;

    PEntryPoint idEntry(const TCharArray& sId, TUint32 hash) const;
    PEntryPoint intEntry(const TIntObj& iKey) const;
    TCseObj getById(const TCharArray& sId, TUint32 hash) const;

    TCseObj get(const TCseObj& key) const;
    const TCseObj& set(const TCseObj& key, const TCseObj& value);
    TCseObj getEx(const TCseObj& key, const TCseObj& vDefault) const;
    TCseObj setEx(const TCseObj& key, const TCseObj& value);
    TBool hasKey(const TCseObj& key) const;

    PEntryPoint transfer(PEntryPoint pOther);
    void clear();
    TCharArray str() const;

    const TCseObj& bind(const TCseObj& value) const;
    TCseObj getBinding() const;
    int fixSize(int iRsvd=0);

    // start with pEntry = NULL
    TBool enumItem(PEntryPoint& pEntry, TCseObj *pKey=NULL, TCseObj *pValue=NULL) const;
};

extern CSE_IMPEXP_IN TBool operator==(const TEntryArray& x, const TEntryArray& y);
extern CSE_IMPEXP_IN TBool operator!=(const TEntryArray& x, const TEntryArray& y);

#endif
